/**
 * 
 */
package org.swing.input.panel;

import java.awt.BorderLayout;
import java.awt.Color;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 * @author lqnhu
 *
 */
public class ComponentExceptionPanel extends JPanel {

	private static final long serialVersionUID = -975497929104417874L;
	public static final int BORDER_THICKNESS = 4;

	public ComponentExceptionPanel(String message, Throwable exception) {
		setLayout(new BorderLayout());
		setBorder(BorderFactory.createCompoundBorder(BorderFactory
				.createEmptyBorder(BORDER_THICKNESS, BORDER_THICKNESS,
						BORDER_THICKNESS, BORDER_THICKNESS), BorderFactory
				.createMatteBorder(1, 1, 1, 1, Color.RED)));
		JLabel label = new JLabel("<html><body>" + message + "<br>"
				+ exception.getClass().getSimpleName() + ":<br>"
				+ exception.getMessage() + "<br>" + "</body></html>",
				JLabel.CENTER);
		label.setForeground(Color.RED);
		add(label, BorderLayout.NORTH);
	}
}
